package io.github.siltal.examsystembackend.dto;

import io.github.siltal.examsystembackend.entity.User;

// 登录成功后，我们返回一个包含 token 的对象
public record LoginResponse(
        Boolean ok,
        Long userId,
        String username,
        String email,
        String error
) {
    public static LoginResponse from(User user) {
        return new LoginResponse(true, user.getId(), user.getUsername(), user.getEmail(), "");
    }

    public static LoginResponse userNotFound() {
        return new LoginResponse(false, -1L, "", "", "用户不存在");
    }

    public static LoginResponse usernameOrPasswordIncorrect() {
        return new LoginResponse(false, -1L, "", "", "用户名或密码错误");
    }

    public static LoginResponse usernameOrPasswordCantBeEmpty() {
        return new LoginResponse(false,  -1L, "","","用户名或密码不能为空");
    }


}